package com.acane.instagram.service.impl;

import com.acane.instagram.mapper.ChatMessageMapper;
import com.acane.instagram.pojo.dto.ChatDTO;
import com.acane.instagram.service.ChatService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatServiceImpl extends ServiceImpl<ChatMessageMapper, ChatDTO>  implements ChatService {
    @Autowired
    private ChatMessageMapper chatMessageMapper;

    @Override
    public void saveMessage(ChatDTO message) {
        chatMessageMapper.insert(message);
    }

    @Override
    public List<ChatDTO> getMessagesByUser(String receiver) {
        return chatMessageMapper.getMessagesByUser(receiver);
    }

    @Override
    public List<ChatDTO> getHistory(String sender, String receiver) {
        return chatMessageMapper.getHistory(sender, receiver);
    }

    @Override
    public List<ChatDTO> getChatList(Integer page, Integer size) {
        return chatMessageMapper.getChatList(page, size);
    }
}
